﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace web
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void sub_bt_Click(object sender, EventArgs e)
        {
            string title = title_tb.Text;
            string content = con_tb.Text;
            string sqlCom = "insert into GuestBook([title],[content]) values('" + title + "','" + content + "')";
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conStr"].ConnectionString);
            SqlCommand com = new SqlCommand(sqlCom, con);
            con.Open();
            int i = com.ExecuteNonQuery();
            if (i > 0)
            {
                Response.Write("<script>alert('留言成功！')</script>");
            }
            else
            {
                Response.Write("<script>alert('留言失败！')</script>");
            }
            con.Close();
        }
    }
}